JAVA_HOME_MAC=/System/Library/Frameworks/JavaVM.framework/Versions/1.6/Home/
JAVA_MAC=/System/Library/Frameworks/JavaVM.framework/Versions/1.6/Home/bin/java
TOMCAT_SCRIPT_MAC=$HOME/Desktop/tomcat/apache-tomcat-6.0.18/bin/catalina.sh

JAVA_LINUX=/usr/bin/java
JAVA_HOME_LINUX=/usr/lib/jvm/java-1.6.0-openjdk-1.6.0.0/jre/
TOMCAT_SCRIPT_LINUX=/usr/sbin/tomcat6
#JAVA=${JAVA_MAC}
#JAVA_HOME=${JAVA_HOME_MAC}

JAVA=${JAVA_LINUX}
JAVA_HOME=${JAVA_HOME_LINUX}
TOMCAT_SCRIPT=${TOMCAT_SCRIPT_LINUX}

JCHAINS_LIB=../jchains.jar 


DIRNAME=.
#:FOUND_RUN_JAR
JCHAINS_CLASSPATH=${JCHAINS_LIB}

JAVA_OPTS="-Dcom.sun.management.jmxremote -Xbootclasspath/a:${JCHAINS_LIB} -Xmx1024M -Dorg.jchains.always=true -Dorg.jchains.emitClass=StandardEmitter -Dorg.jchains.file=tomcat.csv -Djava.security.policy=test.policy -Djava.security.manager=org.jchains.intercept.JChainsSecInterceptor"

JAVA_OPTS_WITH_DEBUG="-Xbootclasspath/a:ia.zip -Dorg.jchains.always=true -Dorg.jchains.emitClass=CORBAEmitter -Dorg.jchains.outputfile=jedit.txt -Dorg.jchains.CNameServiceIOR=corbaloc::127.0.0.1:1050/NameService -Djava.security.policy=test.policy -Djava.security.manager=org.jchains.intercept.JChainsSecInterceptor -Djava.security.debug=all  -Xcheck:jni"
CLASSPATH=${JCHAINS_CLASSPATH}


echo ===============================================================================
echo   JAVA: ${JAVA}
echo   JAVA_OPTS: ${JAVA_OPTS}
echo   CLASSPATH: ${CLASSPATH}
echo ===============================================================================

mkdir tombase
mkdir tombase/tomcat6/conf

cp /etc/tomcat6/tomcat6.conf tom.cfg.orig
cp --copy-contents --preserve=timestamps  -R /usr/share/tomcat6/ tombase/
rm tombase/tomcat6/webapps
mkdir tombase/tomcat6/webapps
cp --copy-contents -R /usr/share/tomcat6/webapps/* tombase/tomcat6/webapps
cp /usr/share/bsh/webapps/bshservlet*.war tombase/tomcat6/webapps
rm  tombase/tomcat6/logs
mkdir tombase/tomcat6/logs
rm  tombase/tomcat6/work
mkdir tombase/tomcat6/work
rm  tombase/tomcat6/temp
mkdir tombase/tomcat6/temp

cp ${TOMCAT_SCRIPT} tomcat.sh
cat tom.cfg.orig| sed -e "s,CATALINA_BASE=\"/usr/share/tomcat6,CATALINA_BASE=\"./tombase/tomcat6,g"  | sed -e "s,/var/run/tomcat6.pid,tomcat6.pid,g" > tomcat.cfg


TOMCAT_CFG=tomcat.cfg JAVA_HOME=$JAVA_HOME JAVA_OPTS=$JAVA_OPTS bash -x -v tomcat.sh start 


